package com.bsc.rtc.lib.libraries.RetrofitNet;


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;

import com.bsc.rtc.lib.libraries.R;
import com.bsc.rtc.lib.libraries.RetrofitNet.OkioDemo.CzzLog;
import com.bsc.rtc.lib.libraries.RetrofitNet.OkioDemo.OkioUtil;
import com.bsc.rtc.lib.libraries.utils.FileUtil;

import java.io.IOException;

public class DownUpLoadActivity extends AppCompatActivity {
    String TAG = "DownUpLoadActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_down_up_load);

    }

    public void createFile(View v) {
        switch (v.getId()) {
            case R.id.createFile:
               // init();
                upload();
               // CzzLog.clear();
                break;
            case R.id.readFile:
                String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp/test/";
                String fileName = "test1.txt";
                new OkioUtil().readFile(filePath,fileName);
                break;
            case R.id.writeFile:
/*                String filePath1 = Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp/log/";
                String fileName1 = "test1.txt";
                new OkioUtil().writeFile(filePath1,fileName1);*/
                CzzLog.d("dfasfdsa");
                CzzLog.d("hahahaha12312fsdjlajlfdaj方法将考虑");
                break;
        }
    }

    private void init() {
        String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp/test/";
        String fileName = "test.txt";
        Log.i(TAG, "filePath= " + filePath+fileName);
       FileUtil.createPath(filePath, fileName);
        String s = "fdsjaklfjlsajf";

        try {
            FileUtil.writeBytesToFile(s.getBytes(), filePath, fileName);
        } catch (IOException e) {
            e.printStackTrace();
        }

        Log.i(TAG,"b="+new String(FileUtil.readFileToByteArray(filePath, fileName)));
    }
    private void upload(){
        String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp/test/";
        String fileName = "test.txt";
        Log.i(TAG, "filePath= " + filePath+fileName);
        FileNetWorkUtils utils=new FileNetWorkUtils();
        utils.upload(filePath+fileName);
    }

}
